<?php

class TestFolder {
  var $files;

  function __construct($path) {
    if ($handle = opendir($path)) {
      $this->files = array();
      while (false !== ($file = readdir($handle))) {
        if (ereg("^test_.*\.php$", $file)) {
          $this->files[] = "$path/$file";
        }
      }

      closedir($handle);
    }
  }


  function run_and_print() {
    if (count($this->files) < 1) {
      echo "<div class=\"NoResults\">No tests found. Check out the help link above.</div>";
      return;
    }

    foreach($this->files as $file) {
      $set = TestSet::load($file);
      $set->run_tests();
      $set->print_all();
    }
  }
}

?>
